#!/bin/bash

#生命科学组件 安装使能脚本，如需要安装randfold，则执行
# sh hpc_life_science.sh randfold
#如需使能应用所有组件，则执行
#sh hpc_life_science.sh

#--------------------------------#
OPT=$1;

##全局变量
#--------------------------------#
passwd=123456;
install_path=/home/sunqian
targetdir=$install_path/BIN
source_file=$install_path/source_sun.sh
cpu_num=`grep -c "processor" /proc/cpuinfo`; #CPU核数
netcard=`cat /proc/net/dev|sort -rn -k2|awk '{print $1}'|awk NR==1|awk -F ':' '{print $1}'`;#网卡名称
ip_addr=`ip a|grep $netcard|grep inet|awk '{print $2}'|awk -F '/' '{print $1}'` #ip地址
osType=`cat /etc/os-release|grep ID |awk NR==1|awk -F \" '{print $2}'`
basearch=`arch`



#--------------------------------#
mkdir -p $targetdir
echo install_path=$install_path >> $source_file
touch $source_file


#--------------------------------#
#下载全部所需的依赖
cd $install_path
yum -y install make gcc g++ git
yum install -y java-1.8.0-openjdk-devel.aarch64 ncurses-devel.aarch64 bzip2-devel.aarch64 python3-devel python bazel cmake3
pip3 install tensorflow


function install_R-4.3.0() {
	install_lapack-3.8.0
	cd $install_path
	wget https://cran.r-project.org/src/base/R-4/R-4.3.0.tar.gz
	tar xvf R-4.3.0.tar.gz
	cd R-4.3.0
	yum install libXt-devel libX11-devel readline-devel libz bzip2-devel liblzma*  xz-devel pcre-devel pcre2-devel libcurl-devel -y
	./configure --prefix=$targetdir/R_4_3_0/R_4_3_0_install
	make -j
	make install
	echo export PATH=$targetdir/R_4_3_0/R_4_3_0_install/bin:$PATH >> $source_file
	echo export LD_LIBRARY_PATH=$targetdir/R_4_3_0/R_4_3_0_install/R/library:$LD_LIBRARY_PATH >> $source_file
}

#GSEA
function install_GSEA() {
	#安装java依赖
	yum install java-11-openjdk-devel.aarch64 -y
	#安装可视化组件
	#yum install xorg-x11-xauth xorg-x11-server-utils xorg-x11-server-Xnest libXtst -y
	#sed -i "s/X11Forwarding no/X11Forwarding yes/g" /etc/ssh/sshd_config
	#systemctl restart sshd.service
	cd $install_path
	wget  https://data.broadinstitute.org/gsea-msigdb/gsea/software/desktop/4.3/GSEA_4.3.2.zip
	unzip GSEA_4.3.2.zip
	echo export PATH=$install_path/GSEA_4.3.2:\$PATH >> $source_file
}

#pangolin
function install_pangolin() {
	#安装依赖
	yum install python3-devel python3 python3-pip git make -y
	cd $install_path
	wget  https://github.com/cov-lineages/pangolin/archive/refs/tags/v4.3.1.tar.gz -O pangolin-v4.3.1.tar.gz
	tar xf pangolin-v4.3.1.tar.gz
	cd pangolin-4.3.1
	pip3 install . -i https://pypi.tuna.tsinghua.edu.cn/simple
	pip3 install git+https://github.com/cov-lineages/pangolin-data.git 
	pip3 install git+https://github.com/cov-lineages/scorpio.git 
	pip3 install git+https://github.com/cov-lineages/constellations.git 
	pip3 install snakemake -i https://pypi.tuna.tsinghua.edu.cn/simple
}



#randfold
function install_randfold() {
	cd $install_path
	git clone https://github.com/eb00/randfold.git
	cd randfold/src/squid-1.9g
	./configure && make
	cd ../
	make
	echo export PATH=$install_path/randfold/src >> $source_file
	}

	#blat
	function install_BLAT() {
	cd $install_path
	wget https://codeload.github.com/djhshih/blat/tar.gz/v35.1 -O blat-35.1.tar.gz
	yum -y install libpng-devel
	tar zxvf blat-35.1.tar.gz
	cd blat-35.1/
	sed -i 's/jmp_buf htmlRecover/\/\/jmp_buf htmlRecover/g' src/inc/htmshell.h
	export MACHTYPE=aarch64
	make
	echo export PATH=$install_path/blat-35.1/bin:\$PATH >> $source_file
}


#BWA
function install_BWA() {
	cd $install_path
	wget  https://sourceforge.net/projects/bio-bwa/files/bwa-0.7.17.tar.bz2
	tar -xvf bwa-0.7.17.tar.bz2
	cd bwa-0.7.17 && wget https://raw.githubusercontent.com/jratcliff63367/sse2neon/master/SSE2NEON.h
	sed -i 's/#include <emmintrin.h>/#include "SSE2NEON.h"/g' ksw.c
	sed -i 's/const uint8_t rle_auxtab/\/\/const uint8_t rle_auxtab/g' rle.h |grep rle_auxtab
	make
	echo export PATH=$install_path/bwa-0.7.17:\$PATH >> $source_file
}



#gatk
function install_gatk() {
	#依赖blat,bwa
	#blat
	install_BLAT
	#BWA
	install_BWA
	#samtools
	install_samtools
	cd $install_path
	wget https://github.com/broadinstitute/gatk/releases/download/4.0.0.0/gatk-4.0.0.0.zip -O gatk-4.0.0.0.zip
	unzip gatk-4.0.0.0.zip
	echo export PATH=$install_path/gatk-4.0.0.0:\$PATH >> $source_file
}


#Rosetta
function install_Rosetta() {
	yum -y install openssl-devel
	pip3 install tensorflow nltk pandas
	pip3 install tensorflow Rosetta
}

#AlphaFold
function install_AlphaFold() {
	pip3 install AlphaFold
}

#STAR
function install_star() {
	cd $install_path
	wget https://github.com/alexdobin/STAR/archive/refs/tags/2.7.1a.tar.gz -O STAR-2.7.1a.tar.gz
	tar -xvf STAR-2.7.1a.tar.gz && cd STAR-2.7.1a
	sed -i 's/\?\=/\?= \-flto \-march=native \-mcpu=tsv110/g' source/Makefile|grep ?
	cd source
	make STAR
	echo export PATH=$install_path/STAR-2.7.1a/source/:\$PATH >> $source_file
}

function install_gcc-9.3.1() {
#安裝gcc
mkdir -p $install_path/gcc
cd $install_path
wget http://mirrors.concertpass.com/gcc/releases/gcc-9.1.0/gcc-9.1.0.tar.xz
wget gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2  
wget gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 
wget gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz   
wget gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2  



#gcc编译依赖gmp、mpfr、mpc、isl四个库，mpfr依赖gmp，isl依赖gmp，而mpc依赖gmp和mpfr，因此安装gcc之前首先根据依赖关系依次安装四个库
 
tar -xvf gcc-9.1.0.tar.xz
tar -xvf gmp-6.1.0.tar.bz2
tar -xvf mpfr-3.1.4.tar.bz2
tar -xvf mpc-1.0.3.tar.gz
tar -xvf mpc-1.0.3.tar.gz


#安装gmp
cd $install_path/gmp-6.1.0
./configure --prefix=$install_path/gcc/gmp-6.1.2
make -j64 && make install
cd ..


#安装mpfr
cd $install_path/mpfr-3.1.4
./configure --prefix=$install_path/gcc/mpfr-3.1.4 --with-gmp=$install_path/gcc/gmp-6.1.2
make  -j64 && make install
cd ..

#安装mpc
cd $install_path/mpc-1.0.3
./configure --prefix=$install_path/gcc/mpc-1.0.3 --with-gmp=$install_path/gcc/gmp-6.1.2 --with-mpfr=$install_path/gcc/mpfr-3.1.4
make -j64 && make install
cd ..

#安装isl
yum -y install gmp-devel
cd $install_path/isl-0.18
./configure --prefix=$install_path/gcc/isl-0.18 --with-gmp=$install_path/gcc/gmp-6.1.2 --with-mpfr=$install_path/gcc/mpfr-3.1.4 --with-mpc=$install_path/gcc/mpc-1.0.3
make -j64 && make install
cd ..

cd $install_path/gcc-9.1.0
mkdir gcc-build-9.1.0
cd gcc-build-9.1.0
rm -rf ../host-aarch64-unknown-linux-gnu
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --prefix=$install_path/gcc/gcc-9.1.0 --with-gmp=$install_path/gcc/gmp-6.1.2 --with-mpfr=$install_path/gcc/mpfr-3.1.4 --with-mpc=$install_path/gcc/mpc-1.0.3 
make -j64 && make install
echo export PATH=$install_path/gcc/gcc-9.1.0/bin/:\$PATH >> $source_file


g++ --version
}

#安裝gcc-10.3.1
function install_gcc() {
	cd $install_path
	wget https://mirrors.huaweicloud.com/kunpeng/archive/compiler/kunpeng_gcc/gcc-10.3.1-2022.06-aarch64-linux.tar.gz
	tar -xvf gcc-10.3.1-2022.06-aarch64-linux.tar.gz
	cd gcc-10.3.1-2022.06-aarch64-linux
	mkdir -p $targetdir/kunpeng-gcc-10.3.1
	cp -rf ./* $targetdir/kunpeng-gcc-10.3.1
	echo export PATH=$targetdir/kunpeng-gcc-10.3.1/bin:\$PATH >> $source_file
	source $source_file
}


function install_go() {
	cd $targetdir
	wget https://golang.google.cn/dl/go1.18.2.linux-arm64.tar.gz
	mkdir -p go_install
	mv go1.18.2.linux-arm64.tar.gz ./go_install
	
	cd ./go_install
	tar -xf go1.18.2.linux-arm64.tar.gz
	yum install environment-modules -y
	source /etc/profile
	cat > $targetdir/go_install/go_modulefiles << EOF
#%Module1.0
conflict go
variable modfile [file normalize [info script]]
proc getModulefileDir {} {
    variable modfile
    set modfile_path [file dirname $modfile]
    return $modfile_path
}
set pwd [getModulefileDir]
set GO_install $pwd
setenv GO_install $GO_install
prepend-path PATH $GO_install/go/bin

EOF
	module use /usr/local/go_install/
	module load /usr/local/go_install/go_modulefiles
	go version

}

#ncbi-vdb
function install_ncbi-vdb() {
	cd $install_path
	wget https://github.com/ncbi/ncbi-vdb/archive/refs/tags/3.0.0.tar.gz -O ncbi-vdb-3.0.0.tar.gz
	yum -y install doxygen cmake
	yum install wget git tar libatomic git openssl glibc-devel libstdc++-static make perl cmake fuse-devel libxml2-devel file-devel patch -y
	tar -xvf ncbi-vdb-3.0.0.tar.gz
	cd ncbi-vdb-3.0.0
	cp -r interfaces/cc/gcc/arm64 interfaces/cc/gcc/aarch64
	./configure --relative-build-out-dir --build-prefix=$targetdir/sratoolkit/ncbi-vdb-3.0.0 --prefix=$targetdir/sratoolkit/ncbi-vdb-3.0.0
	make -j $(nproc) && make install
}


#sratoolkit-3.0.0
function install_sratoolkit() {
	install_ncbi-vdb
	cd $install_path
	wget https://github.com/ncbi/sra-tools/archive/refs/tags/3.0.0.tar.gz -O sratoolkit-3.0.0.tar.gz
	yum install wget git tar libatomic git openssl glibc-devel libstdc++-static make perl cmake fuse-devel libxml2-devel file-devel patch -y
	tar zxvf sratoolkit-3.0.0.tar.gz
	cd sra-tools-3.0.0
	cd tools/sharq/bm/
	wget https://gitee.com/sunlock0653/hpcrunner/raw/master/patch/bmutil.h.patch

	patch -p0 < bmutil.h.patch
	cd ../../../
	cd tools/copycat/
	wget https://gitee.com/sunlock0653/hpcrunner/raw/master/patch/ccsra.c.patch
	patch -p0 < ccsra.c.patch
	cd ../../
	sed -i "s/add_definitions(-msse4.2 -DBMSSE42OPT)/ /" tools/sharq/CMakeLists.txt
	sed -i "s/add_definitions(-msse4.2 -DBMSSE42OPT)/ /" test/sharq/CMakeLists.txt
	cd tools/driver-tool/secure/
	wget https://gitee.com/openeuler/AvxToNeon/blob/master/avx2neon.h
	sed -i 's/#include <intrin.h>/#include <avx2neon.h>/' string.cpp
	cd ../../../
	./configure --relative-build-out-dir --build-prefix=$targetdir/sratoolkit/sra-tools-3.0.0 --prefix=$targetdir/sratoolkit/sra-tools-3.0.0 --with-ncbi-vdb-prefix=$targetdir/sratoolkit/ncbi-vdb-3.0.0
	make -j $(nproc)
	make install

	echo export $targetdir/sratoolkit/sra-tools-3.0.0/bin >> $source_file

}


#cutadapt
function install_cutadapt() {
	pip3 install cutadapt==4.1
	#pip3 install cutadapt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
}



#Bowtie2
function install_Bowtie2() {
	cd $install_path
	wget https://github.com/BenLangmead/bowtie2/archive/refs/tags/v2.4.1.tar.gz -O bowtie2-2.4.1.tar.gz
	yum install zlib.aarch64 zlib-devel.aarch64 zlib-static.aarch64
	tar -xvf bowtie2-2.4.1.tar.gz
	cd bowtie2-2.4.1
	mkdir -p third_party/simde/simde/x86/
	export NO_TBB=1
	export POPCNT_CAPABILITY=0
	wget https://codeload.github.com/simd-everywhere/simde/tar.gz/refs/tags/v0.7.6 -O simde-0.7.6.tar.gz
	tar -xvf simde-0.7.6.tar.gz

	wget https://codeload.github.com/jratcliff63367/sse2neon/zip/refs/heads/master -O sse2neon.zip

	cp -a simde-0.7.6/simde third_party/simde/
	cp sse2neon-master/SSE2NEON.h sse2neon-master/sse2neon.h
	cp -a sse2neon-master/sse2neon.h ./third_party/simde/simde/x86/
	make all
	echo export PATH=$install_path/bowtie2-2.4.1:\$PATH >> $source_file
}



#deeptool 
function install_deeptool() {
	cd $install_path
	wget https://github.com/deeptools/deepTools/archive/refs/tags/3.5.1.tar.gz -O deepTools-3.5.1.tar.gz
	tar -xvf deepTools-3.5.1.tar.gz
	cd $install_path/deepTools-3.5.1
	python3 setup.py install
}



#meme
function install_meme() {
	cd $install_path
	wget https://meme-suite.org/meme/meme-software/5.4.0/meme-5.4.0.tar.gz
	tar -xvf meme-5.4.0.tar.gz
	cd meme-5.4.0
	yum install -y libtool* autoconf automake nodejs* perl* libxml2* libxslt*
	#cpan XML::Simple
	#cpan Sys::info
	#cpan Math::CDF
	#cpan HTML::TreeBuilder.pm
	#cpan JSON
	./configure --prefix=$targetdir/MEME
	make
	make install
	echo export PATH=$targetdir/MEME/bin:\$PATH >> $source_file
}


#ncbi-blast
function install_ncbi-blast() {
	cd $install_path
	wget https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.13.0/ncbi-blast-2.13.0+-src.tar.gz -O ncbi-blast-2.13.0+-src.tar.gz
	tar xzf ncbi-blast-2.13.0+-src.tar.gz
	cd ncbi-blast-2.13.0+-src
	export BLAST_TOP=`pwd`
	export CC=gcc
	export CXX=g++
	cd $BLAST_TOP
	tar -xvf LMDB_0.9.24.tar.gz
	cd lmdb-LMDB_0.9.24
	export LMDB_PATH=$BLAST_TOP/lmdb-LMDB_0.9.24
	cd $BLAST_TOP/c++
	./configure
	cd ReleaseMT/build
	make all_r -j
	make  -j && make install
	cd $BLAST_TOP/c++/ReleaseMT/bin
	ls blastp
	blastp
}

#emboss
function install_emboss() {
	cd $install_path
	wget ftp://emboss.open-bio.org/pub/EMBOSS/old/6.5.0/EMBOSS-6.5.7.tar.gz
	yum install -y epel-release
	yum install -y gcc
	yum install -y gcc-c++
	yum install -y cmake
	yum install -y make
	yum install -y libX11
	yum install -y libX11-devel
	tar -zxvf EMBOSS-6.5.7.tar.gz
	cd EMBOSS-6.5.7/
	./configure --prefix=$targetdir/EMBOSS --build=aarch64-unknown-linux-gnu
	make -j
	make install
	cd $targetdir/EMBOSS/bin
	echo export PATH=$targetdir/EMBOSS/bin:\$PATH >> $source_file
}

#
function install_TRF() {
	cd $install_path
	#git clone https://github.com/Benson-Genomics-Lab/TRF.git
	wget https://github.com/Benson-Genomics-Lab/TRF/archive/refs/tags/v4.09.1.tar.gz -O TRF-4.09.1.tar.gz
	tar -xvf TRF-4.09.1.tar.gz
	cd TRF-4.09.1
	mkdir build
	cd build
	../configure --prefix=$targetdir/RepeatMasker/TRF_install
	make -j
	make install
}

#ncbi-blast-2.10.0
function install_ncbi-blast-2.10.0() {
	cd $install_path
	wget https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.10.0/ncbi-blast-2.10.0+-src.tar.gz
	wget https://www.repeatmasker.org/rmblast/isb-2.10.0+-rmblast.patch.gz
	tar -xvf ncbi-blast-2.10.0+-src.tar.gz
	gunzip isb-2.10.0+-rmblast.patch.gz
	cd ncbi-blast-2.10.0+-src
	patch -p1 < ../isb-2.10.0+-rmblast.patch
	cd c++
	wget https://gitee.com/sunlock0653/hpcrunner/raw/master/patch/B_patch.cpp
	patch $install_path/ncbi-blast-2.10.0+-src/c++/src/build-system/configure ./B_patch.cpp
	./configure --with-mt --without-debug --without-krb5 --without-openssl --with-projects=scripts/projects/rmblastn/project.lst --prefix=$targetdir/rmblast/rmblast_install
	make -j && make
	make install
}

#repeatmaster
function install_repeatmaster() {
	install_TRF
	install_ncbi-blast-2.10.0

	yum install perl perl-CPAN -y
	cd $install_path
	wget http://www.repeatmasker.org/RepeatMasker/RepeatMasker-4.1.2-p1.tar.gz
	tar -xvf RepeatMasker-4.1.2-p1.tar.gz
	cd RepeatMasker
	yum install python3 python3-pip pip3 install h5py
	chmod -R 755 *
	./configure

	#依次输入如下参数，其中$targetdir要替换成变量值
	#$targetdir/RepeatMasker/TRF_install/bin/trf
	# 2
	#$targetdir/rmblast/rmblast_install/bin/
	# y
	#5
	echo export PATH=$install_path/RepeatMasker:\$PATH >> $source_file
}



function install_bats-0.4.0() {
	cd $install_path
	wget https://github.com/sstephenson/bats/archive/refs/tags/v0.4.0.tar.gz
	tar -xvf v0.4.0.tar.gz
	cd bats-0.4.0
	echo export PATH=$install_path/bats-0.4.0/bin:\$PATH >> $source_file
}

function install_pygtftk-1.6.2() {
	install_bats-0.4.0
	cd $install_path
	wget https://github.com/dputhier/pygtftk/archive/refs/tags/v1.6.2.tar.gz
	tar xvf v1.6.2.tar.gz
	cd pygtftk-1.6.2
	pip3 install -r requirements.txt
	pip3 install cython==0.29.30
	python3 setup.py install
}


function install_python-3.11.5() {
	cd $install_path
	wget https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tar.xz
	tar xvf Python-3.11.5.tar.xz
	cd Python-3.11.5
	./configure --prefix=$targetdir/python_3_11_5/python_3_11_5_install
	make -j
	make install
	echo export PATH=$targetdir/python_3_11_5/python_3_11_5_install/bin:\$PATH >> $source_file
	echo export LD_LIBRARY_PATH=$targetdir/python_3_11_5/python_3_11_5_install/lib:$LD_LIBRARY_PATH >> $source_file
	echo export INCLUDE=/$targetdir/python_3_11_5/python_3_11_5_install/include:$INCLUDE >> $source_file
}


function install_snakemake-7.32.4() {
	install_python-3.11.5
	install_BWA
	install_samtools
	cd $install_path
	wget https://files.pythonhosted.org/packages/f4/94/884160dab89886cef7802df0a8c8217bfb2d795427dee01ad0e0dc15964a/snakemake-7.32.4.tar.gz
	tar xvf v7.32.4.tar.gz
	cd snakemake-7.32.4
	pip3 install .
}

function install_lapack-3.8.0() {
	cd $install_path
	wget https://www.cp2k.org/static/downloads/lapack-3.8.0.tgz
	tar xvf lapack-3.8.0.tgz
	cd lapack-3.8.0
	cp make.inc.example make.inc
	sed -i "23s/$/ -fallow-argument-mismatch/g"  make.inc
	sed -i "25s/$/ -fallow-argument-mismatch/g"  make.inc
	mkdir build
	cd build
	cmake ..  -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$targetdir/lapack_3_8_0/lapack_3_8_0_install
	make -j
	make install
	echo export LD_LIBRARY_PATH=$targetdir/lapack_3_8_0/lapack_3_8_0_install/lib:$LD_LIBRARY_PATH >> $source_file
}



function install_scenic-1.3.1() {
	install_R-4.3.0
	cd $install_path
	R -e 'install.packages("BiocManager")'
	R -e 'BiocManager::install("arrow")'
	R -e 'install.packages("devtools")'
	R -e 'devtools::install_github("aertslab/AUCell")'
	R -e 'devtools::install_github("aertslab/RcisTarget")'
	R -e 'devtools::install_github("aertslab/GENIE3")'
	R -e 'BiocManager::install("ggrepel")'
	R -e 'devtools::install_github("aertslab/SCENIC")'
}


function install_uclust() {
	install_R-4.3.0
	cd $install_path
	R -e 'install.packages("uclust")'
}


function install_onemap() {
	install_R-4.3.0
	cd $install_path
	R -e 'install.packages("onemap", dependencies=TRUE)'
}


function install_poppr() {
	install_R-4.3.0
	cd $install_path
	R -e 'install.packages("poppr")'
}



function install_seurat-5.0.0() {
	install_R-4.3.0
	cd $install_path
	wget https://github.com/satijalab/seurat/archive/refs/tags/v5.0.0.tar.gz
	tar xvf v5.0.0.tar.gz
	cd seurat-5.0.0/
	R -e 'install.packages("BiocManager")'
	R -e 'BiocManager::install(c("SeuratObject", "cowplot", "fastDummies", "fitdistrplus", "future", "future.apply", "generics", "ggplot2", "ggrepel", "ggridges", "httr", "ica", "igraph", "irlba", "leiden", "lmtest", "matrixStats", "miniUI", "patchwork", "pbapply", "plotly", "png", "progressr", "RANN", "RColorBrewer", "RcppAnnoy", "RcppHNSW", "reticulate", "ROCR", "RSpectra", "Rtsne", "scales", "scattermore", "sctransform", "shiny", "spatstat.explore", "spatstat.geom", "tibble", "uwot", "RcppEigen", "RcppProgress"))'
	R CMD INSTALL .
}


function install_reditools-2.0() {
	cd $install_path
	yum install environment-modules  openmpi-devel -y
	source /etc/profile
	module load mpi/openmpi-aarch64
	git clone https://github.com/tizianoflati/reditools2.0
	cd reditools2.0
	pip3 install -r requirements.txt
}

#安装openblas
function install_openblas() {
	cd $install_path
	wget https://github.com/xianyi/OpenBLAS/releases/download/v0.3.23/OpenBLAS-0.3.23.tar.gz
	tar -xvf OpenBLAS-0.3.23.tar.gz
	cd OpenBLAS-0.3.23
	make -j 16 ARCH=aarch64 all
	make PREFIX=$targetdir/openblas/openblas_install install
	echo export PATH=$targetdir/openblas/openblas_install/bin:\$PATH >> $source_file
	echo export LD_LIBRARY_PATH=$targetdir/openblas/openblas_install/lib:\$LD_LIBRARY_PATH >> $source_file
}

#安装gsl
function install_gsl() {
	cd $install_path
	wget https://ftpmirror.gnu.org/gsl/gsl-2.7.1.tar.gz
	tar -xf gsl-2.7.1.tar.gz 
	cd gsl-2.7.1/
	./configure --prefix=$targetdir/gsl/gsl_install
	make -j 16
	make install
	echo export PATH=$targetdir/gsl/gsl_install/bin:\$PATH >> $source_file
	echo export LD_LIBRARY_PATH=$targetdir/gsl/gsl_install/lib:\$LD_LIBRARY_PATH >> $source_file
}

#安装admixtools
function install_admixtools() {
	#安装openblas
	install_openblas
	#安装gsl
	install_gsl
	cd $install_path
	wget https://github.com/DReichLab/AdmixTools/archive/v7.0.2.tar.gz
	tar -xf v7.0.2.tar.gz 
	cd AdmixTools-7.0.2/src
	sed -i '14d' Makefile
	sed -i '18d' Makefile
	sed -i "14s%^.*$%override CFLAGS += -I$targetdir/openblas/openblas_install/include -I$targetdir/gsl/gsl_install/include%g" Makefile
	sed -i "15s%^.*$%override LDFLAGS += -L$targetdir/openblas/openblas_install/lib -L$targetdir/gsl/gsl_install/lib%g" Makefile
	make -j 16 
	make install
	mkdir -p $targetdir/admixtools/admixtools_install 
	cp -r ../bin $targetdir/admixtools/admixtools_install/bin
	echo export PATH=$targetdir/admixtools/admixtools_install/bin:\$PATH >> $source_file
}

#安装EIG
function install_EIG() {
	#安装openblas
	install_openblas
	#安装gsl
	install_gsl
	cd $install_path
	wget https://github.com/DReichLab/EIG/archive/refs/tags/v8.0.0.tar.gz
	mv v8.0.0.tar.gz EIG-8.0.0.tar.gz
	tar -xf EIG-8.0.0.tar.gz 
	cd EIG-8.0.0/src 
	sed -i "1s%^.*$%override CFLAGS += -I../include -I$targetdir/openblas/openblas_install/include%g" Makefile
	sed -i '10d' Makefile
	sed -i '12d' Makefile
	sed -i "10s%^.*$%override CFLAGS += -I$targetdir/openblas/openblas_install/include -I$targetdir/gsl/gsl_install/include%g" Makefile
	sed -i "11s%^.*$%override LDFLAGS += -L$targetdir/openblas/openblas_install/lib -L$targetdir/gsl/gsl_install/lib%g" Makefile
	make -j 16 
	make install
	mkdir -p $targetdir/EIG/EIG_install 
	cp -r ../bin $targetdir/EIG/EIG_install 
	cp -r ../include $targetdir/EIG_install
	echo export PATH=$targetdir/EIG_install/bin:\$PATH >> $source_file
}

#安装gdal
function install_gadl() {
	cd $install_path
	yum install proj proj-devel -y
	wget https://download.osgeo.org/gdal/3.7.0/gdal-3.7.0.tar.xz
	tar -xf gdal-3.7.0.tar.xz
	cd gdal-3.7.0/
	mkdir build
	cd build
	cmake ../ -DCMAKE_INSTALL_PREFIX=$targetdir/gdal/gdal_install
	make install
	echo export PATH=$targetdir/gdal/gdal_install/bin:\$PATH >> $source_file
	echo export LD_LIBRARY_PATH=$targetdir/gdal/gdal_install/lib:\$LD_LIBRARY_PATH >> $source_file
}

#安装commot
function install_commot() {
	#安装依赖
	yum install python3-devel python3 python3-pip git make -y
	install_gadl
	source $source_file
	pip install commot -i https://pypi.tuna.tsinghua.edu.cn/simple
}

function install_asset() {
#	安装依赖
	pip3 install asset
}


function install_astral() {
	#安装依赖
	cd $install_path
	wget https://github.com/smirarab/ASTRAL/archive/refs/tags/v5.7.1.tar.gz -O ASTRAL-5.7.1.tar.gz
	tar -zxf ASTRAL-5.7.1.tar.gz
	cd ASTRAL-5.7.1
	sh make.sh
	echo "PATH=$inspath/ASTRAL-5.7.1:$PATH" >> $source_file
}


function install_bayescan() {
	#安装依赖
	cd $install_path
	wget https://github.com/mfoll/BayeScan/archive/refs/tags/v2.1.tar.gz
	tar xvf v2.1.tar.gz
	cd BayeScan-2.1/
	make -j
	echo "PATH=$inspath/BayeScan-2.1:$PATH" >> $source_file
}

function install_daligner() {
	#安装依赖
	cd $install_path
	wget https://github.com/thegenemyers/DALIGNER/archive/refs/tags/V1.0.tar.gz -O DALIGNER-1.0.tar.gz
	tar -zxf DALIGNER-1.0.tar.gz
	cd DALIGNER-1.0/
	make -j
	echo "PATH=$inspath/DALIGNER-1.0:$PATH" >> $source_file
}

function install_ectools() {
	#安装依赖
	cd $install_path
	wget https://github.com/jgurtowski/ectools/archive/refs/tags/v0.1.tar.gz -O ectools-0.1.tar.gz
	tar -xvf  ectools-0.1.tar.gz
	cd ectools-0.1/
	cd test
	../schtats -log -stdout test.sim.fa
}


function install_EVidenceModeler() {
	#安装依赖
	cd $install_path
	yum install -y perl perl-URI
	git clone --recursive https://github.com/EVidenceModeler/EVidenceModeler.git
	cd EVidenceModeler
	git checkout EVidenceModeler-v2.1.0
	sed -i "s/-m64//g" `grep -rl "\-m64"`
	make -j
	cd testing
	./runMe.sh
}


function install_FASconCAT() {
	#安装依赖
	cd $install_path
	git clone https://github.com/PatrickKueck/FASconCAT.git
	cd FASconCAT/
	echo "PATH=$inspath/FASconCAT:$PATH" >> $source_file
}

function install_GMcloser() {
	#安装依赖
	cd $install_path
	wget https://sourceforge.net/projects/gmcloser/files/GMcloser-1.6.2.tar.gz
	tar xvf GMcloser-1.6.2.tar.gz
	cd GMcloser-1.6.2
	./gmcloser -h
}

function install_3d-dna() {
	#安装依赖
	cd $install_path
	git clone https://github.com/theaidenlab/juicer.git
	cd juicer
	ln -s CPU scripts
	cd scripts/common
	wget https://hicfiles.tc4ga.com/public/juicer/juicer_tools.1.9.9_jcuda.0.8.jar
	ln -s juicer_tools.1.9.9_jcuda.0.8.jar  juicer_tools.jar
	cd $install_path
	git clone https://github.com/theaidenlab/3d-dna.git
	./juicer/scripts/juicer.sh -h
	./3d-dna/run-asm-pipeline.sh -h
}



function install_allhic() {
	install_go
	mkdir -p $install_path/allhic
	cd $install_path/allhic
	mkdir src pkg bin
	export GOPATH=$install_path/allhic
	go env -w GO111MODULE=on
	go env -w GOPROXY=https://goproxy.cn,direct
	
	wget https://github.com/tanghaibao/allhic/archive/refs/tags/v0.9.13.tar.gz
	tar -xf v0.9.13.tar.gz
	cd $install_path/allhic/allhic-0.9.13
	go mod init allhic
	go mod tidy
	cd $install_path/allhic/allhic-0.9.13/cmd
	go install main.go
	mv $install_path/allhic/bin/main $install_path/allhic/bin/allhic
	yum install environment-modules -y
	source /etc/profile
	cat > $install_path/allhic/allhic_modulefiles << EOF
#%Module1.0
conflict go
variable modfile [file normalize [info script]]
proc getModulefileDir {} {
      variable modfile
      set modfile_path [file dirname $modfile]
      return $modfile_path
}
set pwd [getModulefileDir]
set allhic $pwd
setenv allhic $allhic
prepend-path PATH $allhic/bin
EOF
	
	echo module use $install_path/allhic >> $source_file
	echo module use $install_path/allhic/allhic_modulefiles >> $source_file
	source $source_file
	allhic --version

	
}



function install_yass() {
	cd $install_path
	wget https://codeload.github.com/laurentnoe/yass/tar.gz/refs/tags/1.16_alpha1 -O yass-1.16_alpha1.tar.gz
	tar -xvf yass-1.16_alpha1.tar.gz
	cd yass-1.16_alpha1/
	autoreconf
	./configure --with-threads --build=aarch64-unknown-linux-gnu
	automake
	make
	cd src
	./yass -v
}


function install_amas() {
	cd $install_path
	#安装依赖
	wget https://codeload.github.com/marekborowiec/AMAS/zip/refs/heads/master -O AMAS.zip
	unzip AMAS.zip
	mv AMAS-master AMAS
	cd AMAS
	pip install virtualenv
	virtualenv AMAS
	source AMAS/bin/activate
	cd $install_path/AMAS/
	ls
	python3 setup.py install
}


function install_htslib() {
	cd $install_path
	wget https://github.com/samtools/htslib/releases/download/1.16/htslib-1.16.tar.bz2
	tar -xvf htslib-1.16.tar.bz2
	cd htslib-1.16
	yum -y install zlib-devel bzip2-devel xz-devel
	./configure
	make -j
	make install
}


function install_angsd() {
	cd $install_path
	install_htslib
	wget http://popgen.dk/software/download/angsd/angsd0.938.tar.gz
	yum -y install curl  curl-devel
	make  HTSSRC=/usr/local/lib
}

function install_yak() {
	cd $install_path
	wget https://codeload.github.com/lh3/yak/tar.gz/refs/tags/v0.1 -O yak-0.1.tar.gz
	tar -xvf yak-0.1.tar.gz
	cd yak-0.1/
	make -j
}


function install_art-nextgen-simulation-tools() {
	cd $install_path
	yum -y install gsl gsl-devel
	wget https://mirror.tuna.tsinghua.edu.cn/raspbian/raspbian/pool/main/a/art-nextgen-simulation-tools/art-nextgen-simulation-tools_20160605%2Bdfsg.orig.tar.xz
	tar -xvf art-nextgen-simulation-tools_20160605+dfsg.orig.tar.xz
	cd art_src_MountRainier_Linux
	autoreconf --install
	./configure --prefix=$install_path/art-nextgen-simulation-tools-install
	make -j
	make install
}

function install_idba() {
	cd $install_path
	wget https://codeload.github.com/abishara/idba/tar.gz/refs/tags/1.1.3a1 -O idba-1.1.3a1.tar.gz
	tar -xvf idba-1.1.3a1.tar.gz
	cd idba-1.1.3a1/
	./build.sh
}


#samtools
function install_samtools() {
	#gcc-10.3.1
	cd $install_path
	wget https://codeload.github.com/samtools/samtools/tar.gz/0.1.9 -O samtools-0.1.9.tar.gz
	tar -xvf samtools-0.1.9.tar.gz
	cd samtools-0.1.9
	make
	echo export PATH=$install_path/samtools-0.1.9:\$PATH >> $source_file
}


function install_samtools-1.16.1() {
	cd $install_path
	wget https://github.com/samtools/samtools/releases/download/1.16.1/samtools-1.16.1.tar.bz2
	tar -xvf samtools-1.16.1.tar.bz2
	cd samtools-1.16.1
	make -j && make install
}

function install_minimap2() {
	git clone https://github.com/lh3/minimap2.git
	cd minimap2/
	make arm_neno=1 aarch64=1
}


function install_flye() { #bug
	cd $install_path
	install_gcc
	git clone https://github.com/fenderglass/Flye.git
	cd Flye/
	git checkout 2.3.1
	cd ./lib/minimap2
	wget https://raw.githubusercontent.com/DLTcollab/sse2neon/master/sse2neon.h
	cd -
	sed -i 's/<emmintrin.h>/\"sse2neon.h\"/g' ./lib/minimap2/ksw2_ll_sse.c
	python setup.py install
}

function install_szip() {
	cd $install_path
	wget https://distfiles.macports.org/szip/szip-2.1.1.tar.gz
	tar xf szip-2.1.1.tar.gz
	cd szip-2.1.1/
	./configure --prefix=$install_path/sizp
	make && make install
}

function install_hdf5() {
	cd $install_path
	wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.12/src/hdf5-1.8.12.tar.gz
	tar xf hdf5-1.8.12.tar.gz
	cd hdf5-1.8.12
	./configure  --enable-cxx --enable-static=yes --enable-shared --prefix=$install_path/hdf5/hdf5-1.8.12 --build=arm LDFLAGS="-L$install_path/szip/szip-2.1.1/lib" CPPFLAGS="-I$install_path/szip/szip-2.1.1/include"
	make -j
	make install
}


function install_blasr() {
	wget https://codeload.github.com/BioinformaticsArchive/blasr/zip/refs/heads/master -O blasr-master.zip
	unzip blasr-master.zip
	cd blasr-master/
	sed -i "5c\HDF5INCLUDEDIR=$install_path/hdf5/hdf5-1.8.12/include" common.mk
	sed -i "6c\HDF5LIBDIR=$install_path/hdf5/hdf5-1.8.12/lib" common.mk
	sed -i "s/\-static//g" `grep -rnl "\-static"`
	sed -i "13s/$/ -ldl/" common.mk
	sed -i "33s/testIn/testIn.good()/g" ./common/data/hdf/HDFFile.h
	sed -i "242c\ (unsigned int) curPrefix.tuple + 1 < (unsigned int) (this->lookupTableLength));" ./common/datastructures/suffixarray/SuffixArray.h
	sed -i "2271s/cout <<//g" ./pbihdfutils/LoadPulses2.cpp
	sed -i "128s/ ==/.good() ==/" ./common/datastructures/alignmentset/SAMAlignment.h
	make
	$install_path/blasr-master/alignment/bin/blasr -h
}

function install_breakdancer() { #bug
	cd $install_path
	git clone --recursive https://github.com/genome/breakdancer.git
	cd breakdancer/
	mkdir build && cd build
	cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=$install_path/breakdancerd
	make && make install
}




function install_cmake() {
	cd $install_path
	yum -y install openssl openssl-devel mesa-libGL-devel mesa-libGLU-devel
	wget https://cmake.org/files/v3.24/cmake-3.24.1.tar.gz
	tar -xvf cmake-3.24.1.tar.gz && cd cmake-3.24.1
	./bootstrap
	make && make install
	/usr/local/bin/cmake --version
}


function install_idba_ud() { #bug
	cd $install_path
	install_cmake
	git clone https://github.com/1928d/idba_ud.git
	cd idba_ud/
	mkdir build
	cd build
	cmake ..
	make
}

function install_CNCI() { #bug
	cd $install_path
	git clone https://github.com/www-bioinfo-org/CNCI.git
	cd CNCI/
	unzip libsvm-3.0.zip
	cd libsvm-3.0
	make
}

function install_bisheng() {
	version=3.2.0
	wget https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_compiler/BiShengCompiler-$version-aarch64-linux.tar.gz
	mkdir -p /opt/compiler
	cp BiShengCompiler-*-aarch64-linux.tar.gz /opt/compiler
	cd /opt/compiler
	tar -zxvf BiShengCompiler-*-aarch64-linux.tar.gz
	export PATH=/opt/compiler/BiShengCompiler-$version-aarch64-linux/bin:$PATH 
	export LD_LIBRARY_PATH=/opt/compiler/BiShengCompiler-$version-aarch64-linux/lib:$LD_LIBRARY_PATH

}



function install_qtl() {
	install_R-4.3.0
	cd $install_path
	R -e 'install.packages("qtl")'
}


function install_eigen() {
	cd $install_path
	wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
	tar -xf eigen-3.4.0.tar.gz
	cd eigen-3.4.0
	mkdir build
	cd build
	cmake .. -DCMAKE_INSTALL_PREFIX:STRING=$install_path/eigen
	make
	
	make install
}


function install_iqtree() {
	cd $install_path
	install_eigen
	git clone https://github.com/joshlvmh/iqtree_arm_neon.git
	cd iqtree_arm_neon/
	cd IQ-TREE/
	mkdir build
	cd build
	cmake .. -DCMAKE_INSTALL_PREFIX:STRING=cd $install_path/iqtree -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DBUILD_TESTING:BOOL=OFF -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON -DCMAKE_PREFIX_PATH:STRING=$install_path/eigen
	make
	make install
}

function install_ruby() {
	yum -y install ruby-devel
}

function install_glean() {
	install_ruby
	gem install glean
}


function install_phylip() {
	yum -y install clang clang-devel
	git clone https://github.com/dunnlab/phylip.git
	cd phylip/
	cd phylip-3.697/
	cd src/
	sed -i 's/gcc/clang/g' Makefile.unx |grep clang
	sed -i 's/\-g \-pg/\-Wl,\-z,muldefs/g' Makefile.unx |grep CC
	make -f Makefile.unx install
}

function install_libgtextutils() {
	cd $install_path
	wget https://github.com/agordon/libgtextutils/releases/download/0.7/libgtextutils-0.7.tar.gz
	tar -xvf libgtextutils-0.7.tar.gz
	cd libgtextutils-0.7/
	./reconf
	./configure --prefix=/path/to/libgtextutils-0.7 --build=aarch64-unknown-linux-gnu
	make
	make install
}

function install_mugsy() {
	conda activate mugsy
	conda install -c bioconda mugsy
}


function install_mugsy() {
	cd $install_path
	wget https://github.com/UCSC-LoweLab/tRNAscan-SE/archive/refs/tags/v2.0.9.tar.gz
	tar -xvf v2.0.9.tar.gz
	cd tRNAscan-SE-2.0.9/
	./configure
	make -j
}


function install_glimmer() {
	cd $install_path
	wget http://ccb.jhu.edu/software/glimmer/glimmer302b.tar.gz
	tar -xvf glimmer302b.tar.gz
	cd glimmer3.02/
	cd src
	make
	make install
	echo export PATH=/path/to/Glimmer/glimmer3.02/bin/:\$PATH >> $source_file
}

function install_ViennaRNA() {
	cd $install_path
	wget https://www.tbi.univie.ac.at/RNA/download/sourcecode/2_4_x/ViennaRNA-2.4.4.tar.gz
	tar -zxvf ViennaRNA-2.4.4.tar.gz
	cd ViennaRNA-2.4.4/
	cd ViennaRNA-2.4.4
	./configure --prefix=/path/to/ViennaRNA -build=arm-linux
	make
	make install
}



function install_hifiasm() {
	cd  $install_path
	git clone https://github.com/chhylp123/hifiasm.git
	git clone https://github.com/DLTcollab/sse2neon.git
	export C_INCLUDE_PATH=$install_path/sse2neon
	export CPLUS_INCLUDE_PATH=$install_path/sse2neon
	sed -i 's/#include <emmintrin.h>/#include <sse2neon.h>/g' ksw2_extz2_sse.c
	sed -i 's/#include <immintrin.h>/#include <sse2neon.h>/g' Levenshtein_distance.h
	sed -i 's/#include \"smmintrin.h\"//g' Levenshtein_distance.h
	sed -i 's/#include \"nmmintrin.h\"//g' Levenshtein_distance.h
	sed -i 's/#include \"emmintrin.h\"//g' Levenshtein_distance.h
	make
}

yum -y install python3 python3-devel python3-pip
pip install virtualenv




function install_taxonkit() {
	cd  $install_path
	install_go
	git clone https://github.com/shenwei356/taxonkit
	cd taxonkit/taxonkit/
	go build
	echo export PATH=$install_path/taxonkit/taxonkit:\$PATH >> $source_file
}




function install_cdhit() { #bug
	install_bisheng
	wget https://github.com/weizhongli/cdhit/archive/refs/tags/V4.8.1.tar.gz
	tar -xvf V4.8.1.tar.gz
	cd cdhit-4.8.1
	sed -i "1,3s/g++/clang/g" Makefile
	make
}


function install_raxml-ng() { 
	git clone --recursive https://github.com/amkozlov/raxml-ng.git
	cd raxml-ng/
	mkdir build && cd build
	cmake ..
	make install
}

function install_interval() { 
	cd  $install_path
	pip2 install docopt==0.6.2
	pip2 install pysam
	git clone https://github.com/kepbod/interval.git
	cd interval/
	python2 setup.py install
	echo export PATH=$install_path/interval/build/lib:$PATH >> $source_file
}


function install_CIRCexplorer() { 
	cd  $install_path
	install_interval
	wget https://github.com/YangLab/CIRCexplorer/archive/refs/tags/1.1.10.tar.gz
	tar -xvf 1.1.10.tar.gz
	cd CIRCexplorer-1.1.10/
	python2 setup.py install
	CIRCexplorer.py -h
}



function install_wise() { #bug 
	install_gcc
	wget https://src.fedoraproject.org/repo/extras/wise2/wise2.4.1.tar.gz/d70c404c1dc40ceef7718757b11bdaa0/wise2.4.1.tar.gz
	tar -xvf wise2.4.1.tar.gz
	cd wise2.4.1
	cd src/
	find . -name  makefile | xargs sed -i 's/glib-config/pkg-config glib-2.0/'
	perl -p -i -e 's/getline/getline_ReadSeqVars/g' ./HMMer2/sqio.c
	perl -p -i -e 's/isnumber/isdigit/' models/phasemodel.c
	perl -p -i -e's/csh welcome.csh/sh welcome.csh/' makefile
	sed -i 's/-ldyna_glib/-ldyna_glib `pkg-config --libs glib-2.0`/' models/makefile
	make all
}


function install_beast() {
	cd  $install_path
	wget https://github.com/CompEvol/beast2/releases/download/v2.7.0/BEAST.v2.7.0.Linux.aarch64.tgz
	tar xvf BEAST.v2.7.0.Linux.aarch64.tgz
	yum -y install java-devel
	echo export PATH=$install_path/beast/bin/:$PATH >> $source_file
}



function install_bioperl() {
	pip2 install numpy
	pip2 install biopython==1.76
	wget -O - https://install.perlbrew.pl | bash
	cd /root/perl5/perlbrew/bin/
	./perlbrew install-cpanm
	./cpanm install Bio::Perl
}

function install_CPC() {
	cd  $install_path
	install_bioperl
	wget http://cpc2.gao-lab.org/data/CPC2-beta.tar.gz
	tar -xf  CPC2-beta.tar.gz
	cd CPC2-beta/
	export CPC_HOME=`pwd`
	cd libs/libsvm/
	tar -xf libsvm-3.18.tar.gz
	cd libsvm-3.18/
	make
	sed -i -e "s/print \(.*\)/print \(\1\)/g" ./bin/seqio.py
	sed -i "s/ file(/ open(/g" ./bin/CPC2.py
	python2 bin/CPC2.py
}

function install_hpcrunner() {
	cd  $install_path
	git clone https://gitee.com/sunlock0653/hpcrunner.git
}

function install_CMAQ() {
	install_hpcrunner
	cd  $install_path/hpcrunner
	git checkout EA-1.0
	source ./init.sh
	./jarvis -use templates/CMAQ/5.3.1/data.CMAQ.arm_kgcc.cpu.config
	./jarvis -d
	./jarvis -dp
	./jarvis -b
	
	module use $install_path/hpcrunner/software/modulefiles
	module purge
	module load kgcc/9.3.1
	module load hmpi/1.1.1
	module load hdf5/1.10.1
	module load netcdf/4.7.0
	module load optimized-routines/20.02
	module load ioapi/3.2
}

function install_wavewatch() {
	cd  $install_path
	git clone https://github.com/NOAA-EMC/WW3.git
	./model/bin/w3_setup model -c Gnu -s NCEP_st4
	export WWATCH3_NETCDF=NC4
	export NETCDF_CONFIG=`which nc-config`

	cd model/bin 
	./w3_automake
}


function install_POM() {
	install_CMAQ
	module use $install_path/hpcrunner/software/modulefiles
	module purge
	module load kgcc/9.3.1
	module load hmpi/1.1.1
	module load hdf5/1.10.1
	module load netcdf/4.7.0
	module load optimized-routines/20.02
	module load ioapi-kgcc/3.2
		
	cd  $install_path
	wget -r -p -k -np -nc -e robots=off http://www.ccpo.odu.edu/POMWEB/GRID-DATA
	wget -r -p -k -np -nc -e robots=off http://www.ccpo.odu.edu/POMWEB/POM2K
	cd  $install_path/www.ccpo.odu.edu/POMWEB/POM2K
	rm -rf runpom2k
	wget https://gitee.com/sunlock0653/hpcrunner/raw/EA-1.0/wait_file/runpom2k
	chmod 755 runpom2k
	./runpom2k
}

function install_camx() {
	wget https://www.camx.com/getmedia/CAMx_v7.20.src.220430.tgz
	module use $install_path/hpcrunner/software/modulefiles
	module purge
	module load kgcc/9.3.1
	module load hmpi/1.1.1
	module load hdf5/1.10.1
	module load netcdf/4.7.0
	module load optimized-routines/20.02
	sed -i -e  "s#\/usr\/local\/mpich3#${install_path}/hpcrunner\/software\/mpi\/hmpi1.1.1-kgcc9.3.1\/1.1.1#g" Makefile
	cd ./MPI/util
	sed -i -e  "s#\/usr\/local\/mpich-3.0.4.pgi.2019.CE#${install_path}/hpcrunner\/software\/mpi\/hmpi1.1.1-kgcc9.3.1\/1.1.1#g" Makefile
	cd -
	make COMPILER=gfortran CONFIG=v7.20 MPI=mpich3 IEEE=true
}


function install_swan() {
	install_cmake
	git clone https://gitlab.tudelft.nl/citg/wavemodels/swan.git && cd swan
	mkdir build && cd build
	cmake .. -G Ninja
	cmake --build .
}

function install_mitgcm() {
	cd  $install_path
	module use $install_path/hpcrunner/software/modulefiles
	module purge
	module load kgcc/9.3.1
	module load hmpi/1.1.1
	module load hdf5/1.10.1
	module load netcdf/4.7.0
	wget http://mitgcm.org/download/other_checkpoints/MITgcm_c67o.tar.gz
	tar -xvf MITgcm_c67o.tar.gz
	git clone https://gitee.com/kp-hpc-mod/hpc-patch.git
	patch -p0 < hpc-patch/patch_file/MITgcm_c67o.patch
	cd MITgcm
	cd verification/exp4/build
	../../../tools/genmake2 -mods=../code -mpi -of=../../../tools/build_options/linux_arm64_gfortran
	make depend
	make -j
}


function create_virtualenv(){
	cd  $install_path
	pip3 install virtualenv  -i https://pypi.tuna.tsinghua.edu.cn/simple
	yum install python3 python3-devel python3-pip
	python3 -m virtualenv $install_path
	#pip2 install virtualenv  -i https://pypi.tuna.tsinghua.edu.cn/simple
	#yum install python2 python2-devel python2-pip
	#python -m virtualenv $install_path
	source $install_path/bin/activate
}

function install_cpat() {
	pip3 install cpat
}

function install_CIRI() {
	wget https://sourceforge.net/projects/ciri/files/CIRI2/CIRI_v2.0.6.zip
	unzip CIRI_v2.0.6.zip
	cd CIRI_v2.0.6/
}


function install_trimmomatic() {
	wget  https://github.com/timflutre/trimmomatic/archive/refs/heads/master.zip
	unzip master.zip.2
	cd trimmomatic-master/
	make -j
	make install INSTALL=/path/to/trimmomatic-install

}


function install_spliceGrapher() {
	cd $install_path
	wget https://master.dl.sourceforge.net/project/splicegrapher/SpliceGrapher-0.2.7.tgz
	tar -xvf SpliceGrapher-0.2.7.tgz
	rm -rf SpliceGrapher-0.2.7.tgz
	git clone https://gitee.com/kp-hpc-mod/hpc-patch.git
	patch -p0 < hpc-patch/patch_file/SpliceGrapher-0.2.7.patch
	tar -zcvf SpliceGrapher-0.2.7.tgz SpliceGrapher-0.2.7
	pip3 install SpliceGrapher-0.2.7.tgz
	#pip2 install SpliceGrapher-0.2.7.tgz
}


function install_svmu() {
	wget https://codeload.github.com/mahulchak/svmu/tar.gz/refs/tags/0.3-alpha -O svmu-0.3-alpha.tar.gz
	tar -xvf svmu-0.3-alpha.tar.gz
	cd svmu-0.3-alpha/
	make
}

function install_MrBayes() {
	cd $install_path
	wget https://codeload.github.com/NBISweden/MrBayes/tar.gz/refs/tags/v3.2.7 -O MrBayes-3.2.7.tar.gz
	tar -xvf MrBayes-3.2.7.tar.gz
	cd MrBayes-3.2.7/
	./configure
	make && sudo make install
}

function install_tapis() {
	create_virtualenv
	install_spliceGrapher
	pip3 install numpy bx-python pysam matplotlib streams  -i https://pypi.tuna.tsinghua.edu.cn/simple
	pip3 install django-activity-stream -i https://pypi.tuna.tsinghua.edu.cn/simple
	cd $install_path
	git clone https://bitbucket.org/singhbit/tapis.git
	cd $install_path/tapis
	python3 setup.py build
	pip3 install .
}



conda create -n envname python=3.8
conda activate envname
pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install cython -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install mdtraj -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install pandas>=1.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
cd $install_path
git clone https://github.com/LQCT/MDScan.git 
cd MDScan/
pip3 install . -i https://pypi.tuna.tsinghua.edu.cn/simple




function install_htslib() {
	yum install zlib-devel bzip2 bzip2-devel xz-devel -y
	cd $install_path
	wget https://github.com/samtools/htslib/releases/download/1.10.2/htslib-1.10.2.tar.bz2
	tar -jxvf htslib-1.10.2.tar.bz2
	cd htslib-1.10.2/
	./configure --prefix=cd $install_path/htslib
	make -j
	make install
	ln -s /usr/local/lib/libhts.so.3 /usr/lib/libhts.so.3
	sudo ldconfig
}

function install_pindel() {
	install_htslib
	cd $install_path
	git clone https://github.com/genome/pindel.git
	cd pindel/
	./INSTALL ../htslib-1.10.2
	./INSTALL ../htslib-1.10.2
	./bam2pindel.pl
	
}



function install_szip() {
	cd $install_path
	wget https://distfiles.macports.org/szip/szip-2.1.1.tar.gz
	tar xf szip-2.1.1.tar.gz
	cd szip-2.1.1
	./configure --prefix=/path/to/szip
	make
	make install
}

function install_networkx() {
	wget https://pypi.tuna.tsinghua.edu.cn/packages/f1/8e/f6f345ed7b228d080e338eac5a6bcce2260390468ae9130dcb67096f59c4/networkx-1.1.tar.gz
	tar -xvf networkx-1.1.tar.gz
	cd networkx-1.1
	python setpu.py install
}

function install_pysam() {
	wget https://pypi.tuna.tsinghua.edu.cn/packages/a4/ea/901d47d5621f15c05079dcf45e746a77bab21dbf0f9ce272993a3ca3a367/pysam-0.8.0.tar.gz
	tar -xvf pysam-0.8.0.tar.gz
	cd pysam-0.8.0/
	python setup.py install
}





function install_blasr() {
	pip install intervaltree==2.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
	pip install intervaltree-bio==1.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
	install_networkx
	pip install numpy==1.16.6 -i https://pypi.tuna.tsinghua.edu.cn/simple
	pip install PyIntervalTree==0.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
	install_pysam
	pip install PyVCF==0.6.8 -i https://pypi.tuna.tsinghua.edu.cn/simple
	install_hdf5
	cd $install_path
	git clone https://github.com/HWsunqian0027/blasr.git
	export HDF5INCLUDEDIR= $install_path/hdf5/hdf5-1.8.12/include
	export HDF5LIBDIR= $install_path/hdf5/hdf5-1.8.12/lib/
	cd blasr/
	make
}


function install_PBSuite() {
	wget https://sourceforge.net/projects/pb-jelly/files/PBSuite_15.8.24.tgz
	tar -xvf PBSuite_15.8.24.tgz
	cd PBSuite_15.8.24/
	a=`pwd`
	sed -i "s#SWEETPATH=.*#SWEETPATH=$a#g" setup.sh
	source ./setup.sh
	./bin/Jelly.py --help
}





function install_clustalw() {
	wget http://www.clustal.org/download/current/clustalw-2.1.tar.gz
	tar -xvf clustalw-2.1.tar.gz
	mv config.guess config.guess_bak
	mv config.sub config.sub_bak
	cp /usr/share/automake-1.16/config.* .
	./configure
	make
}







function install_hycom() {
cd  $install_path
wget https://github.com/HYCOM/HYCOM-src/releases/download/2.3.01/HYCOM-src_2.3.01.tar.gz
chsh -s /bin/csh
module use $install_path/hpcrunner/software/modulefiles
module purge
module load kgcc/9.3.1
module load hmpi/1.1.1
tar -xvf HYCOM-src_2.3.01.tar.gz
#wget https://gitee.com/-/ide/project/kp-hpc-mod/hpc-patch/edit/master/-/patch_file/HYCOM-src_2.3.01.patch
git clone https://gitee.com/kp-hpc-mod/hpc-patch.git
patch -p0 < hpc-patch/patch_file/HYCOM-src_2.3.01.patch
cd HYCOM-src_2.3.01/
./Make.csh
chsh -s /bin/bash
}




#------exagear--------------------#
if [ "$1" == "bayenv2_public" ];then
	git clone https://bitbucket.org/tguenther/bayenv2_public.git
	./bayenv2  -i hgdp_no_X_37_freqs -e PCs.env  -m hgdp_matrix_1 -s samplesize.txt -k 10 -p 10
fi


wget https://github.com/CEMPD/SMOKE/archive/refs/tags/SMOKEv5_Jun2023.tar.gz
tar -xvf SMOKEv5_Jun2023.tar.gz
cd SMOKE-SMOKEv5_Jun2023/scripts/install
chmod +x smoke_install_v47.csh
./smoke_install_v47.csh




if [ ! -n "$OPT" ]; then
install_$OPT

else
source $source_file
fi